package com.expert.miniapp.dao;

import jakarta.persistence.*;
import lombok.Data;

import java.time.LocalDateTime;

/**
 * Case实体类 - 案例信息
 *
 * @author System
 * @since 2025-10-19
 */
@Entity
@Table(name = "`case`")  // case是MySQL保留关键字，需要使用反引号
@Data
public class Case {

    /**
     * 案例ID（主键）
     */
    @Id
    @Column(name = "case_id", length = 36, nullable = false)
    private String caseId;

    /**
     * 用户ID（外键 → user表）
     */
    @Column(name = "user_id", length = 36, nullable = false)
    private String userId;

    /**
     * 需求ID（外键 → demand表）
     */
    @Column(name = "demand_id", length = 36, nullable = false)
    private String demandId;

    /**
     * 资源类型（枚举值）
     * 可选值: expert, achievement, instrument, laboratory, other_resource
     */
    @Column(name = "resource_type", length = 50, nullable = false)
    private String resourceType;

    /**
     * 资源ID（动态外键，根据resource_type关联不同的资源表）
     */
    @Column(name = "resource_id", length = 36, nullable = false)
    private String resourceId;

    /**
     * 推荐项ID（外键 → recommendation_item表）
     */
    @Column(name = "item_id", length = 36)
    private String itemId;

    /**
     * 案例序号（自增，用于排序和显示总数）
     */
    @Column(name = "num")
    private Integer num;

    /**
     * 创建时间
     */
    @Column(name = "created_at", columnDefinition = "DATETIME DEFAULT CURRENT_TIMESTAMP")
    private LocalDateTime createdAt;
}
